package com.joolun.system.service.impl;

import java.util.List;

import com.joolun.common.corp.TenantContext;
import com.joolun.common.utils.DateUtils;
import com.joolun.system.domain.vo.EduCourseChapterVo;
import org.springframework.beans.factory.annotation.Autowired;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.stereotype.Service;
import com.joolun.system.mapper.EduCourseChapterMapper;
import com.joolun.system.domain.EduCourseChapter;
import com.joolun.system.service.IEduCourseChapterService;

/**
 * 课程章节Service业务层处理
 * 
 * @author joolun
 * @date 2025-02-27
 */
@Service
public class EduCourseChapterServiceImpl extends  ServiceImpl<EduCourseChapterMapper, EduCourseChapter> implements IEduCourseChapterService
{
    @Autowired
    private EduCourseChapterMapper eduCourseChapterMapper;

    /**
     * 查询课程章节
     * 
     * @param chapterId 课程章节主键
     * @return 课程章节
     */
    @Override
    public EduCourseChapter selectEduCourseChapterByChapterId(Long chapterId)
    {
        return eduCourseChapterMapper.selectEduCourseChapterByChapterId(chapterId);
    }

    /**
     * 查询课程章节列表
     * 
     * @param eduCourseChapter 课程章节
     * @return 课程章节
     */
    @Override
    public List<EduCourseChapterVo> selectEduCourseChapterList(EduCourseChapter eduCourseChapter)
    {
        // 添加主体id
        eduCourseChapter.setCorpId(TenantContext.getTenantId());
        return eduCourseChapterMapper.selectEduCourseChapterList(eduCourseChapter);
    }

    /**
     * 新增课程章节
     * 
     * @param eduCourseChapter 课程章节
     * @return 结果
     */
    @Override
    public int insertEduCourseChapter(EduCourseChapter eduCourseChapter)
    {
        // 添加主体id
        eduCourseChapter.setCorpId(TenantContext.getTenantId());
        eduCourseChapter.setCreateTime(DateUtils.getNowDate());
        return eduCourseChapterMapper.insertEduCourseChapter(eduCourseChapter);
    }

    /**
     * 修改课程章节
     * 
     * @param eduCourseChapter 课程章节
     * @return 结果
     */
    @Override
    public int updateEduCourseChapter(EduCourseChapter eduCourseChapter)
    {
        eduCourseChapter.setUpdateTime(DateUtils.getNowDate());
        return eduCourseChapterMapper.updateEduCourseChapter(eduCourseChapter);
    }

    /**
     * 批量删除课程章节
     * 
     * @param chapterIds 需要删除的课程章节主键
     * @return 结果
     */
    @Override
    public int deleteEduCourseChapterByChapterIds(Long[] chapterIds)
    {
        return eduCourseChapterMapper.deleteEduCourseChapterByChapterIds(chapterIds);
    }

    /**
     * 删除课程章节信息
     * 
     * @param chapterId 课程章节主键
     * @return 结果
     */
    @Override
    public int deleteEduCourseChapterByChapterId(Long chapterId)
    {
        return eduCourseChapterMapper.deleteEduCourseChapterByChapterId(chapterId);
    }
}
